﻿package com.cw.war.ui
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	/**
	 * @author DanielLu
	 */
	public class EventDispatcher2 extends EventDispatcher
	{
		public function EventDispatcher2 ( target : IEventDispatcher = null )
		{
			super ( target );
		}

		private var dispatchEnabled : Boolean = true;

		public function setDispatchEnabled ( dispatchEnabled : Boolean ) : void
		{
			this.dispatchEnabled = dispatchEnabled;
		}

		public function isDispatchEnabled () : Boolean
		{
			return this.dispatchEnabled;
		}

		override public function dispatchEvent ( event : Event ) : Boolean
		{
			if (this.dispatchEnabled)
			{
				return super.dispatchEvent ( event );
			}
			return false;
		}
	}
}
